package com.example.mapp;

import com.example.entity.supervision.PlanDetail;
import com.example.mapp.buildSql.SupervisionMappSql;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * Created by simon on 2018/8/7.
 */
@Mapper
public interface PlanDetailMapp {

    @Insert(" insert into plan_detail (plan_dict_id, be_cked_party_id, be_cked_party_name, be_party_type, rspon_party_id," +
            " rspon_party_name, check_date, check_reson, is_adjustment, adj_date, adj_reason,rspon_user_id, rspon_user_name, check_state, ext1, ext2,program_name,check_type) " +
            " value (#{planDictId},#{beCkedPartyId},#{beCkedPartyName}," +
            "#{bePartyType},#{rsponPartyId},#{rsponPartyName},#{checkDate},#{checkReson}," +
            "#{isAdjustment},#{adjDate},#{adjReason},#{rsponUserId},#{rsponUserName},#{checkState},#{ext1},#{ext2},#{programName},#{checkType}) ")
    @SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id", before = false, resultType = Long.class)
    int insert(PlanDetail planDetail) throws Exception;

    @Delete("delete from plan_detail where id=#{id}")
    int delete(String id) throws Exception;

    @Update("update plan_detail set plan_dict_id=#{planDictId},be_cked_party_id=#{beCkedPartyId},be_cked_party_name=#{beCkedPartyName}, " +
            "be_party_type=#{bePartyType},rspon_party_id=#{rsponPartyId},rspon_party_name=#{rsponPartyName},check_date=#{checkDate},check_reson=#{checkReson}," +
            "is_adjustment=#{isAdjustment},adj_date=#{adjDate},adj_reason=#{adjReason},rspon_user_id=#{rsponUserId},rspon_user_name=#{rsponUserName}," +
            "check_state=#{checkState},ext1=#{ext1}, ext2=#{ext2},program_name=#{programName},check_type=#{checkType} where id=#{id}")
    int update(Map planDict) throws Exception;

    @Update("update plan_detail set "+
            "check_state=#{checkState} where id=#{id}")
    int updateState(Map planDict) throws Exception;

    @SelectProvider(type = SupervisionMappSql.class, method = "queryPlanDetail")
    List<Map> query(Map map) throws Exception;

    @SelectProvider(type = SupervisionMappSql.class, method = "queryPlanDetailTotal")
    Map queryTotal(Map map) throws Exception;

    @SelectProvider(type = SupervisionMappSql.class, method = "queryProgramList")
    String[] queryProgramList(Map map) throws Exception;
}
